package com.study.service.impl;

import com.study.bean.entity.Dormitory;
import com.study.bean.entity.Student;
import com.study.bean.query.DormitoryQuery;
import com.study.bean.vo.DormitoryVO;
import com.study.dao.impl.DormitoryDaoImpl;
import com.study.service.DormitoryService;
import com.study.util.PageInfo;

import java.util.List;

public class DormitoryServiceImpl implements DormitoryService {
    private DormitoryDaoImpl dormitoryDao = new DormitoryDaoImpl();

    @Override
    public PageInfo selectByPage(DormitoryQuery dormitoryQuery) {
        List<DormitoryVO> list = dormitoryDao.selectByPage(dormitoryQuery);
        //现在要搜索的是符合条件的总的数量
        int totalCount = dormitoryDao.selectTotalCount(dormitoryQuery);

        return PageInfo.ok(totalCount, list);
    }

    @Override
    public Boolean addDormitory(Dormitory dormitory) {

        Integer i = dormitoryDao.addDormitory(dormitory);
        if (i==1){
            return true;
        }
        return false;
    }

    @Override
    public List<Student> viewStu(DormitoryQuery dormitoryQuery) {

        List<Student> students = dormitoryDao.viewStu(dormitoryQuery);
        return students;
    }

}
